#!/usr/bin/env python
# A class to connect the GUI, Utilities, and Data Structures

# Basic imports to take care of joining the paths and some basic GUI functions
import sys, os, wx

# Join the GUI path
completeName = os.path.join('GUI')
sys.path.append(completeName)

# Join the data structures path
completeName = os.path.join('dataStructures')
sys.path.append(completeName)

# Join the utilities path
completeName = os.path.join('utilities')
sys.path.append(completeName)

# Import those classes
import mainWindow, publicClass, rapidEntryGUI, reportGeneratorGUI, fileHelper

class eaplOPTS:
	def __init__(self):
		# The lists that will contain the item objects
		self.silentAuctionItems = []
		self.liveAuctionItems = []
		self.giveAwayItems = []
		self.cashDonations = []
		self.doorPrizes = []
		self.raffleItems = []
		self.expenses = []
		self.saveFileLocation = ""
		self.fileOpened = False
		self.rapidEntryWindow = None
		self.reportWindow = None
		self.rapidOutput = -1 # Tells the application where to put the rapid entry info
		
		# Create our main window
		self.app = wx.PySimpleApp(0)
		wx.InitAllImageHandlers()
		self.mainWindow = mainWindow.mainFrame(self, None, -1, "")
		self.app.SetTopWindow(self.mainWindow)
		self.mainWindow.Show()
		self.app.MainLoop()
	
	def startOver(self, event): # clear all data and start over
		self.fileOpened = False
		
		# Set up cash table (going alphabetically)
		self.mainWindow.cashTable.DeleteRows(0, self.mainWindow.cashTable.GetNumberRows(), True)
		self.cashDonations = []
		
		# Set up door prizes table (going alphabetically)
		self.mainWindow.doorPrizesTable.DeleteRows(0, self.mainWindow.doorPrizesTable.GetNumberRows(), True)
		self.doorPrizes = []
		
		# Set up expense table (going alphabetically)
		self.mainWindow.expenseTable.DeleteRows(0, self.mainWindow.expenseTable.GetNumberRows(), True)
		self.expenses = []
		
		# Set up give away table (going alphabetically)
		self.mainWindow.giveAwayTable.DeleteRows(0, self.mainWindow.giveAwayTable.GetNumberRows(), True)
		self.giveAwayItems = []
		
		# Set up live auction table (going alphabetically)
		self.mainWindow.liveAuctionTable.DeleteRows(0, self.mainWindow.liveAuctionTable.GetNumberRows(), True)
		self.liveAuctionItems = []
		
		# Set up raffle items table (going alphabetically)
		self.mainWindow.raffleItemsTable.DeleteRows(0, self.mainWindow.raffleItemsTable.GetNumberRows(), True)
		self.raffleItems = []
		
		# Set up silent auction table (going alphabetically)
		self.mainWindow.silentAuctionTable.DeleteRows(0, self.mainWindow.silentAuctionTable.GetNumberRows(), True)
		self.silentAuctionItems = []
		event.Skip()

	def saveFile(self, event): # save the current information
		print "attempting generic save"
		if self.fileOpened == False:
			print "User asked to save file, but has not specified where. Will treat as save as"
			fileDiag = wx.FileDialog(self.mainWindow, "Save database as:", wildcard="EAPL Database(*.eapl)|*.eapl", style=wx.FD_OVERWRITE_PROMPT)
			if fileDiag.ShowModal()==wx.ID_OK:
				self.fileOpened = True
				self.saveFileLocation = fileDiag.GetPath()
				fileHelper.saveFile(self.silentAuctionItems, self.liveAuctionItems, self.giveAwayItems, self.cashDonations, self.doorPrizes, self.raffleItems, self.expenses, self.saveFileLocation)
		else: fileHelper.saveFile(self.silentAuctionItems, self.liveAuctionItems, self.giveAwayItems, self.cashDonations, self.doorPrizes, self.raffleItems, self.expenses, self.saveFileLocation)
		event.Skip()

	def saveFileAs(self, event): # allow user to select destination file
		fileDiag = wx.FileDialog(self.mainWindow, "Save database as:", wildcard="EAPL Database(*.eapl)|*.eapl", style=wx.FD_OVERWRITE_PROMPT)
		if fileDiag.ShowModal()==wx.ID_OK:
			self.fileOpened = True
			self.saveFileLocation = fileDiag.GetPath()
			fileHelper.saveFile(self.silentAuctionItems, self.liveAuctionItems, self.giveAwayItems, self.cashDonations, self.doorPrizes, self.raffleItems, self.expenses, self.saveFileLocation)
		event.Skip()

	def openFile(self, event): # open a saved file
		fileDiag = wx.FileDialog(self.mainWindow, "Open database:", wildcard="EAPL Database(*.eapl)|*.eapl", style=wx.FD_OPEN)
		if fileDiag.ShowModal()==wx.ID_OK:
			self.saveFileLocation = fileDiag.GetPath()
			self.silentAuctionItems, self.liveAuctionItems, self.giveAwayItems, self.cashDonations, self.doorPrizes, self.raffleItems, self.expenses = fileHelper.openFile(self.saveFileLocation)
			
			# Set up cash table (going alphabetically)
			self.mainWindow.cashTable.DeleteRows(0, self.mainWindow.cashTable.GetNumberRows(), True)
			for item in self.cashDonations: self.displayCashDonation(item)
			
			# Set up door prizes table (going alphabetically)
			self.mainWindow.doorPrizesTable.DeleteRows(0, self.mainWindow.doorPrizesTable.GetNumberRows(), True)
			for item in self.doorPrizes: self.displayDoorPrize(item)
			
			# Set up expense table (going alphabetically)
			self.mainWindow.expenseTable.DeleteRows(0, self.mainWindow.expenseTable.GetNumberRows(), True)
			for item in self.expenses: self.displayExpense(item)
			
			# Set up give away table (going alphabetically)
			self.mainWindow.giveAwayTable.DeleteRows(0, self.mainWindow.giveAwayTable.GetNumberRows(), True)
			for item in self.giveAwayItems: self.displayGiveAway(item)
			
			# Set up live auction table (going alphabetically)
			self.mainWindow.liveAuctionTable.DeleteRows(0, self.mainWindow.liveAuctionTable.GetNumberRows(), True)
			for item in self.liveAuctionItems: self.displayLiveItem(item)
			
			# Set up raffle items table (going alphabetically)
			self.mainWindow.raffleItemsTable.DeleteRows(0, self.mainWindow.raffleItemsTable.GetNumberRows(), True)
			for item in self.raffleItems: self.displayRaffleItem(item)
			
			# Set up silent auction table (going alphabetically)
			self.mainWindow.silentAuctionTable.DeleteRows(0, self.mainWindow.silentAuctionTable.GetNumberRows(), True)
			for item in self.silentAuctionItems: self.displaySilentItem(item)
			
			self.fileOpened = True
		event.Skip()

	def addSilentItem(self, event): # add an item to the silent auction
		newSilentItem = publicClass.SilentAuctionItem()
		self.silentAuctionItems.append(newSilentItem)
		self.displaySilentItem(newSilentItem)
		event.Skip()

	def deleteSilentItem(self, event): # delete an item from the silent auction
		selectedRow = self.mainWindow.silentAuctionTable.GetGridCursorRow()
		self.mainWindow.silentAuctionTable.DeleteRows(selectedRow, 1, True)
		del(self.silentAuctionItems[selectedRow])
		event.Skip()

	def sortSilentItems(self, event): # sort the silent auction items
		print "Event handler `sortSilentItems' not implemented!"
		event.Skip()

	def searchSilent(self, event): # serach the silent auction items
		print "Event handler `searchSilent' not implemented!"
		event.Skip()

	def reportSilent(self, event): # generate a report of the silent auction items
		self.reportWindow = reportGeneratorGUI.createReportGeneratorWindow(self, "Generate Silent Auction Report", ["Donor", "Contact", "Date", "Phone", "Street Address", "City", "State", "Zip", "Date", "Mailing Address", "Mailing City", "Mailing State", "Mailing Zip", "E-mail", "Value", "Item Number", "Category", "Item", "EAPL Contact", "Sold For"])
		event.Skip()

	def startSilentAuction(self, event): # start a silent auction to enter the values paid for each item
		print "Event handler `startSilentAuction' not implemented!"
		event.Skip()
	
	def openSilentRapidEntry(self, event): # Open the rapid entry window
		# Open the rapid entry
		self.rapidEntryWindow = rapidEntryGUI.createRapidEntryWindow(self, self.mainWindow, "Silent Auction Rapid Entry", ["Donor:", "Contact:", "Date:", "Phone:", "Street Address:", "City:", "State:", "Zip:", "Mailing Address:", "Mailing City:", "Mailing State:", "Mailing Zip:", "E-mail:", "Value:", "Item Number:", "Category:", "Item:", "EAPL Contact:", "Sold For:"])
		self.disableRapidEntryButtons()
		self.rapidOutput = 0
		event.Skip()
	
	def changeSilentInfo(self, event): # Called when a change is made to the silent auction table
		print "changing item data"
		col = event.GetCol()
		i = event.GetRow()
		if col == 0: self.silentAuctionItems[i].date = self.mainWindow.silentAuctionTable.GetCellValue(i, col)
		elif col == 1: self.silentAuctionItems[i].itemNum = self.mainWindow.silentAuctionTable.GetCellValue(i, col)
		elif col == 2: self.silentAuctionItems[i].donor = self.mainWindow.silentAuctionTable.GetCellValue(i, col)
		elif col == 3: self.silentAuctionItems[i].category = self.mainWindow.silentAuctionTable.GetCellValue(i, col)
		elif col == 4: self.silentAuctionItems[i].item = self.mainWindow.silentAuctionTable.GetCellValue(i, col)
		elif col == 5: self.silentAuctionItems[i].value = float(self.mainWindow.silentAuctionTable.GetCellValue(i, col))
		elif col == 6: self.silentAuctionItems[i].soldFor = float(self.mainWindow.silentAuctionTable.GetCellValue(i, col))
		elif col == 7: self.silentAuctionItems[i].contact = self.mainWindow.silentAuctionTable.GetCellValue(i, col)
		elif col == 8: self.silentAuctionItems[i].phone = self.mainWindow.silentAuctionTable.GetCellValue(i, col)
		elif col == 9: self.silentAuctionItems[i].email = self.mainWindow.silentAuctionTable.GetCellValue(i, col)
		elif col == 10: self.silentAuctionItems[i].streetAddress = self.mainWindow.silentAuctionTable.GetCellValue(i, col)
		elif col == 11: self.silentAuctionItems[i].city = self.mainWindow.silentAuctionTable.GetCellValue(i, col)
		elif col == 12: self.silentAuctionItems[i].state = self.mainWindow.silentAuctionTable.GetCellValue(i, col)
		elif col == 13: self.silentAuctionItems[i].zip = self.mainWindow.silentAuctionTable.GetCellValue(i, col)
		elif col == 14: self.silentAuctionItems[i].mailAddress = self.mainWindow.silentAuctionTable.GetCellValue(i, col)
		elif col == 15: self.silentAuctionItems[i].mailCity = self.mainWindow.silentAuctionTable.GetCellValue(i, col)
		elif col == 16: self.silentAuctionItems[i].mailState = self.mainWindow.silentAuctionTable.GetCellValue(i, col)
		elif col == 17: self.silentAuctionItems[i].mailZip = self.mainWindow.silentAuctionTable.GetCellValue(i, col)
		elif col == 18: self.silentAuctionItems[i].eaplContact = self.mainWindow.silentAuctionTable.GetCellValue(i, col)
		event.Skip()
	
	def displaySilentItem(self, item):
		self.mainWindow.silentAuctionTable.AppendRows(1, True)
		i = self.mainWindow.silentAuctionTable.GetNumberRows()-1 # New row number
		self.mainWindow.silentAuctionTable.SetCellValue(i, 0, item.date)
		if item.itemNum == -1: self.mainWindow.silentAuctionTable.SetCellValue(i, 1, "Not Avail.")
		else: self.mainWindow.silentAuctionTable.SetCellValue(i, 1, item.itemNum)
		self.mainWindow.silentAuctionTable.SetCellValue(i, 2, item.donor)
		self.mainWindow.silentAuctionTable.SetCellValue(i, 3, item.category)
		self.mainWindow.silentAuctionTable.SetCellValue(i, 4, item.item)
		self.mainWindow.silentAuctionTable.SetCellValue(i, 5, str(item.value))
		self.mainWindow.silentAuctionTable.SetCellValue(i, 6, str(item.soldFor))
		self.mainWindow.silentAuctionTable.SetCellValue(i, 7, item.contact)
		self.mainWindow.silentAuctionTable.SetCellValue(i, 8, item.phone)
		self.mainWindow.silentAuctionTable.SetCellValue(i, 9, item.email)
		self.mainWindow.silentAuctionTable.SetCellValue(i, 10, item.streetAddress)
		self.mainWindow.silentAuctionTable.SetCellValue(i, 11, item.city)
		self.mainWindow.silentAuctionTable.SetCellValue(i, 12, item.state)
		self.mainWindow.silentAuctionTable.SetCellValue(i, 13, item.zipcode)
		self.mainWindow.silentAuctionTable.SetCellValue(i, 14, item.mailAddress)
		self.mainWindow.silentAuctionTable.SetCellValue(i, 15, item.mailCity)
		self.mainWindow.silentAuctionTable.SetCellValue(i, 16, item.mailState)
		self.mainWindow.silentAuctionTable.SetCellValue(i, 17, item.mailZipcode)
		self.mainWindow.silentAuctionTable.SetCellValue(i, 18, item.eaplContact)
		
	def addLiveItem(self, event): # add an item to the live auction
		newLiveItem = publicClass.LiveAuctionItem()
		self.displayLiveItem(newLiveItem)
		self.liveAuctionItems.append(newLiveItem)
		event.Skip()

	def deleteLiveItem(self, event): # delete an item from the live auction
		selectedRow = self.mainWindow.liveAuctionTable.GetGridCursorRow()
		self.mainWindow.liveAuctionTable.DeleteRows(selectedRow, 1, True)
		del(self.liveAuctionItems[selectedRow])
		event.Skip()

	def sortLiveItems(self, event): # sort the live auction items
		print "Event handler `sortLiveItems' not implemented!"
		event.Skip()

	def searchLive(self, event): # search the live auction items
		print "Event handler `searchLive' not implemented!"
		event.Skip()

	def reportLive(self, event): # generate a report of the live auction items
		self.reportWindow = reportGeneratorGUI.createReportGeneratorWindow(self, "Generate Live Auction Report", ["Donor", "Contact", "Date", "Phone", "Street Address", "City", "State", "Zip", "Mailing Address", "Mailing City", "Mailing State", "Mailing Zip", "E-mail", "Value", "Item Number", "Category", "Item", "EAPL Contact", "Sold For"])
		event.Skip()

	def startLiveAuction(self, event): # start a live auction
		print "Event handler `startLiveAuction' not implemented!"
		event.Skip()
	
	def changeLiveInfo(self, event): # Called when a change is made to the live auction table
		print "changing item data"
		col = event.GetCol()
		i = event.GetRow()
		if col == 0: self.liveAuctionItems[i].date = self.mainWindow.liveAuctionTable.GetCellValue(i, col)
		elif col == 1: self.liveAuctionItems[i].itemNum = self.mainWindow.liveAuctionTable.GetCellValue(i, col)
		elif col == 2: self.liveAuctionItems[i].donor = self.mainWindow.liveAuctionTable.GetCellValue(i, col)
		elif col == 3: self.liveAuctionItems[i].category = self.mainWindow.liveAuctionTable.GetCellValue(i, col)
		elif col == 4: self.liveAuctionItems[i].item = self.mainWindow.liveAuctionTable.GetCellValue(i, col)
		elif col == 5: self.liveAuctionItems[i].value = float(self.mainWindow.liveAuctionTable.GetCellValue(i, col))
		elif col == 6: self.liveAuctionItems[i].soldFor = float(self.mainWindow.liveAuctionTable.GetCellValue(i, col))
		elif col == 7: self.liveAuctionItems[i].contact = self.mainWindow.liveAuctionTable.GetCellValue(i, col)
		elif col == 8: self.liveAuctionItems[i].phone = self.mainWindow.liveAuctionTable.GetCellValue(i, col)
		elif col == 9: self.liveAuctionItems[i].email = self.mainWindow.liveAuctionTable.GetCellValue(i, col)
		elif col == 10: self.liveAuctionItems[i].streetAddress = self.mainWindow.liveAuctionTable.GetCellValue(i, col)
		elif col == 11: self.liveAuctionItems[i].city = self.mainWindow.liveAuctionTable.GetCellValue(i, col)
		elif col == 12: self.liveAuctionItems[i].state = self.mainWindow.liveAuctionTable.GetCellValue(i, col)
		elif col == 13: self.liveAuctionItems[i].zip = self.mainWindow.liveAuctionTable.GetCellValue(i, col)
		elif col == 14: self.liveAuctionItems[i].mailAddress = self.mainWindow.liveAuctionTable.GetCellValue(i, col)
		elif col == 15: self.liveAuctionItems[i].mailCity = self.mainWindow.liveAuctionTable.GetCellValue(i, col)
		elif col == 16: self.liveAuctionItems[i].mailState = self.mainWindow.liveAuctionTable.GetCellValue(i, col)
		elif col == 17: self.liveAuctionItems[i].mailZip = self.mainWindow.liveAuctionTable.GetCellValue(i, col)
		elif col == 18: self.liveAuctionItems[i].eaplContact = self.mainWindow.liveAuctionTable.GetCellValue(i, col)
		event.Skip()
		
	def openLiveRapidEntry(self, event): # Open the rapid entry window
		# Open the rapid entry
		self.rapidEntryWindow = rapidEntryGUI.createRapidEntryWindow(self, self.mainWindow, "Live Auction Rapid Entry", ["Donor:", "Contact:", "Date:", "Phone:", "Street Address:", "City:", "State:", "Zip:", "Mailing Address:", "Mailing City:", "Mailing State:", "Mailing Zip:", "E-mail:", "Value:", "Item Number:", "Category:", "Item:", "EAPL Contact:", "Sold For:"])
		self.disableRapidEntryButtons()
		self.rapidOutput = 1
		event.Skip()
	
	def displayLiveItem(self, item):
		self.mainWindow.liveAuctionTable.AppendRows(1, True)
		i = self.mainWindow.liveAuctionTable.GetNumberRows()-1 # New row number
		self.mainWindow.liveAuctionTable.SetCellValue(i, 0, item.date)
		if item.itemNum == -1: self.mainWindow.liveAuctionTable.SetCellValue(i, 1, "Not Avail.")
		else: self.mainWindow.liveAuctionTable.SetCellValue(i, 1, str(item.itemNum))
		self.mainWindow.liveAuctionTable.SetCellValue(i, 2, item.donor)
		self.mainWindow.liveAuctionTable.SetCellValue(i, 3, item.category)
		self.mainWindow.liveAuctionTable.SetCellValue(i, 4, item.item)
		self.mainWindow.liveAuctionTable.SetCellValue(i, 5, str(item.value))
		self.mainWindow.liveAuctionTable.SetCellValue(i, 6, str(item.soldFor))
		self.mainWindow.liveAuctionTable.SetCellValue(i, 7, item.contact)
		self.mainWindow.liveAuctionTable.SetCellValue(i, 8, item.phone)
		self.mainWindow.liveAuctionTable.SetCellValue(i, 9, str(item.email))
		self.mainWindow.liveAuctionTable.SetCellValue(i, 10, item.streetAddress)
		self.mainWindow.liveAuctionTable.SetCellValue(i, 11, item.city)
		self.mainWindow.liveAuctionTable.SetCellValue(i, 12, item.state)
		self.mainWindow.liveAuctionTable.SetCellValue(i, 13, item.zipcode)
		self.mainWindow.liveAuctionTable.SetCellValue(i, 14, item.mailAddress)
		self.mainWindow.liveAuctionTable.SetCellValue(i, 15, item.mailCity)
		self.mainWindow.liveAuctionTable.SetCellValue(i, 16, item.mailState)
		self.mainWindow.liveAuctionTable.SetCellValue(i, 17, item.mailZipcode)
		self.mainWindow.liveAuctionTable.SetCellValue(i, 18, item.eaplContact)
	
	def addGiveAwayItem(self, event): # add an item to the Give Away auction
		newGiveAway = publicClass.GiveAwayItem()
		self.displayGiveAway(newGiveAway)
		self.giveAwayItems.append(newGiveAway)
		event.Skip()

	def deleteGiveAwayItem(self, event): # delete an item from the Give Away auction
		selectedRow = self.mainWindow.giveAwayTable.GetGridCursorRow()
		self.mainWindow.giveAwayTable.DeleteRows(selectedRow, 1, True)
		del(self.giveAwayItems[selectedRow])
		event.Skip()

	def sortGiveAwayItems(self, event): # sort the Give Away auction items
		print "Event handler `sortGiveAwayItems' not implemented!"
		event.Skip()

	def searchGiveAway(self, event): # search the Give Away auction items
		print "Event handler `searchGiveAway' not implemented!"
		event.Skip()

	def reportGiveAway(self, event): # generate a report of the Give Away auction items
		self.reportWindow = reportGeneratorGUI.createReportGeneratorWindow(self, "Generate Give Away Items Report", ["Donor", "Contact", "Date", "Phone", "Street Address", "City", "State", "Zip", "Mailing Address", "Mailing City", "Mailing State", "Mailing Zip", "E-mail", "Value", "Item Number", "Category", "Item", "EAPL Contact"])
		event.Skip()
	
	def openGiveAwayRapidEntry(self, event): # Open the rapid entry window
		# Open the rapid entry
		self.rapidEntryWindow = rapidEntryGUI.createRapidEntryWindow(self, self.mainWindow, "Give Aways Rapid Entry", ["Donor:", "Contact:", "Date:", "Phone:", "Street Address:", "City:", "State:", "Zip:", "Mailing Address:", "Mailing City:", "Mailing State:", "Mailing Zip:", "E-mail:", "Value:", "Item Number:", "Category:", "Item:", "EAPL Contact:"])
		self.disableRapidEntryButtons()
		self.rapidOutput = 2
		event.Skip()
	
	def changeGiveAwayInfo(self, event): # Called when a change is made to the give aways table
		print "changing item data"
		col = event.GetCol()
		i = event.GetRow()
		if col == 0: self.giveAwayItems[i].date = self.mainWindow.giveAwayTable.GetCellValue(i, col)
		elif col == 1: self.giveAwayItems[i].itemNum = self.mainWindow.giveAwayTable.GetCellValue(i, col)
		elif col == 2: self.giveAwayItems[i].donor = self.mainWindow.giveAwayTable.GetCellValue(i, col)
		elif col == 3: self.giveAwayItems[i].category = self.mainWindow.giveAwayTable.GetCellValue(i, col)
		elif col == 4: self.giveAwayItems[i].item = self.mainWindow.giveAwayTable.GetCellValue(i, col)
		elif col == 5: self.giveAwayItems[i].value = float(self.mainWindow.giveAwayTable.GetCellValue(i, col))
		elif col == 6: self.giveAwayItems[i].contact = self.mainWindow.giveAwayTable.GetCellValue(i, col)
		elif col == 7: self.giveAwayItems[i].phone = self.mainWindow.giveAwayTable.GetCellValue(i, col)
		elif col == 8: self.giveAwayItems[i].email = self.mainWindow.giveAwayTable.GetCellValue(i, col)
		elif col == 9: self.giveAwayItems[i].streetAddress = self.mainWindow.giveAwayTable.GetCellValue(i, col)
		elif col == 10: self.giveAwayItems[i].city = self.mainWindow.giveAwayTable.GetCellValue(i, col)
		elif col == 11: self.giveAwayItems[i].state = self.mainWindow.giveAwayTable.GetCellValue(i, col)
		elif col == 12: self.giveAwayItems[i].zip = self.mainWindow.giveAwayTable.GetCellValue(i, col)
		elif col == 13: self.giveAwayItems[i].mailAddress = self.mainWindow.giveAwayTable.GetCellValue(i, col)
		elif col == 14: self.giveAwayItems[i].mailCity = self.mainWindow.giveAwayTable.GetCellValue(i, col)
		elif col == 15: self.giveAwayItems[i].mailState = self.mainWindow.giveAwayTable.GetCellValue(i, col)
		elif col == 16: self.giveAwayItems[i].mailZip = self.mainWindow.giveAwayTable.GetCellValue(i, col)
		elif col == 17: self.giveAwayItems[i].eaplContact = self.mainWindow.giveAwayTable.GetCellValue(i, col)
		event.Skip()
	
	def displayGiveAway(self, item):
		self.mainWindow.giveAwayTable.AppendRows(1, True)
		i = self.mainWindow.giveAwayTable.GetNumberRows()-1 # New row number
		self.mainWindow.giveAwayTable.SetCellValue(i, 0, item.date)
		if item.itemNum == -1: self.mainWindow.giveAwayTable.SetCellValue(i, 1, "Not Avail.")
		else: self.mainWindow.giveAwayTable.SetCellValue(i, 1, item.itemNum)
		self.mainWindow.giveAwayTable.SetCellValue(i, 2, item.donor)
		self.mainWindow.giveAwayTable.SetCellValue(i, 3, item.category)
		self.mainWindow.giveAwayTable.SetCellValue(i, 4, item.item)
		self.mainWindow.giveAwayTable.SetCellValue(i, 5, str(item.value))
		self.mainWindow.giveAwayTable.SetCellValue(i, 6, item.contact)
		self.mainWindow.giveAwayTable.SetCellValue(i, 7, item.phone)
		self.mainWindow.giveAwayTable.SetCellValue(i, 8, item.email)
		self.mainWindow.giveAwayTable.SetCellValue(i, 9, item.streetAddress)
		self.mainWindow.giveAwayTable.SetCellValue(i, 10, item.city)
		self.mainWindow.giveAwayTable.SetCellValue(i, 11, item.state)
		self.mainWindow.giveAwayTable.SetCellValue(i, 12, item.zipcode)
		self.mainWindow.giveAwayTable.SetCellValue(i, 13, item.mailAddress)
		self.mainWindow.giveAwayTable.SetCellValue(i, 14, item.mailCity)
		self.mainWindow.giveAwayTable.SetCellValue(i, 15, item.mailState)
		self.mainWindow.giveAwayTable.SetCellValue(i, 16, item.mailZipcode)
		self.mainWindow.giveAwayTable.SetCellValue(i, 17, item.eaplContact)
	
	def startGiveAwayAuction(self, event): # start giving away items
		print "Event handler `startGiveAwayAuction' not implemented!"
		event.Skip()
	
	def addDoorPrizes(self, event): # add an item to the Give Away auction
		newDoorPrize = publicClass.GiveAwayItem()
		self.displayDoorPrize(newDoorPrize)
		self.doorPrizes.append(newDoorPrize)
		event.Skip()

	def deleteDoorPrizes(self, event): # delete an item from the Give Away auction
		selectedRow = self.mainWindow.doorPrizesTable.GetGridCursorRow()
		del(self.doorPrizes[selectedRow])
		self.mainWindow.doorPrizesTable.DeleteRows(selectedRow, 1, True)
		event.Skip()

	def sortDoorPrizes(self, event): # sort the Give Away auction items
		print "Event handler `sortdoorPrizes' not implemented!"
		event.Skip()

	def searchDoorPrizes(self, event): # search the Give Away auction items
		print "Event handler `searchDoorPrizes' not implemented!"
		event.Skip()

	def reportDoorPrizes(self, event): # generate a report of the Give Away auction items
		self.reportWindow = reportGeneratorGUI.createReportGeneratorWindow(self, "Generate Door Prizes Report", ["Donor", "Contact", "Date", "Phone", "Street Address", "City", "State", "Zip", "Mailing Address", "Mailing City", "Mailing State", "Mailing Zip", "E-mail", "Value", "Item Number", "Category", "Item", "EAPL Contact"])
		event.Skip()
	
	def startDoorPrizesAuction(self, event): # start the door prizes give away
		print "Event handler `reportDoorPrizes' not implemented!"
		event.Skip()
		
	def openDoorPrizesRapidEntry(self, event): # Open the rapid entry window
		self.rapidEntryWindow = rapidEntryGUI.createRapidEntryWindow(self, self.mainWindow, "Door Prizes Rapid Entry", ["Donor:", "Contact:", "Date:", "Phone:", "Street Address:", "City:", "State:", "Zip:", "Mailing Address:", "Mailing City:", "Mailing State:", "Mailing Zip:", "E-mail:", "Value:", "Item Number:", "Category:", "Item:", "EAPL Contact:"])
		self.disableRapidEntryButtons()
		self.rapidOutput = 3
		event.Skip()
	
	def changeDoorPrizesInfo(self, event): # Called when a change is made to the door prizes table
		print "changing item data"
		col = event.GetCol()
		i = event.GetRow()
		if col == 0: self.doorPrizes[i].date = self.mainWindow.doorPrizesTable.GetCellValue(i, col)
		elif col == 1: self.doorPrizes[i].itemNum = self.mainWindow.doorPrizesTable.GetCellValue(i, col)
		elif col == 2: self.doorPrizes[i].donor = self.mainWindow.doorPrizesTable.GetCellValue(i, col)
		elif col == 3: self.doorPrizes[i].category = self.mainWindow.doorPrizesTable.GetCellValue(i, col)
		elif col == 4: self.doorPrizes[i].item = self.mainWindow.doorPrizesTable.GetCellValue(i, col)
		elif col == 5: self.doorPrizes[i].value = float(self.mainWindow.doorPrizesTable.GetCellValue(i, col))
		elif col == 6: self.doorPrizes[i].contact = self.mainWindow.doorPrizesTable.GetCellValue(i, col)
		elif col == 7: self.doorPrizes[i].phone = self.mainWindow.doorPrizesTable.GetCellValue(i, col)
		elif col == 8: self.doorPrizes[i].email = self.mainWindow.doorPrizesTable.GetCellValue(i, col)
		elif col == 9: self.doorPrizes[i].streetAddress = self.mainWindow.doorPrizesTable.GetCellValue(i, col)
		elif col == 10: self.doorPrizes[i].city = self.mainWindow.doorPrizesTable.GetCellValue(i, col)
		elif col == 11: self.doorPrizes[i].state = self.mainWindow.doorPrizesTable.GetCellValue(i, col)
		elif col == 12: self.doorPrizes[i].zip = self.mainWindow.doorPrizesTable.GetCellValue(i, col)
		elif col == 13: self.doorPrizes[i].mailAddress = self.mainWindow.doorPrizesTable.GetCellValue(i, col)
		elif col == 14: self.doorPrizes[i].mailCity = self.mainWindow.doorPrizesTable.GetCellValue(i, col)
		elif col == 15: self.doorPrizes[i].mailState = self.mainWindow.doorPrizesTable.GetCellValue(i, col)
		elif col == 16: self.doorPrizes[i].mailZip = self.mainWindow.doorPrizesTable.GetCellValue(i, col)
		elif col == 17: self.doorPrizes[i].eaplContact = self.mainWindow.doorPrizesTable.GetCellValue(i, col)
		event.Skip()
	
	def displayDoorPrize(self, item):
		self.mainWindow.doorPrizesTable.AppendRows(1, True)
		i = self.mainWindow.doorPrizesTable.GetNumberRows()-1 # New row number
		self.mainWindow.doorPrizesTable.SetCellValue(i, 0, item.date)
		if item.itemNum == -1: self.mainWindow.doorPrizesTable.SetCellValue(i, 1, "Not Avail.")
		else: self.mainWindow.doorPrizesTable.SetCellValue(i, 1, item.itemNum)
		self.mainWindow.doorPrizesTable.SetCellValue(i, 2, item.donor)
		self.mainWindow.doorPrizesTable.SetCellValue(i, 3, item.category)
		self.mainWindow.doorPrizesTable.SetCellValue(i, 4, item.item)
		self.mainWindow.doorPrizesTable.SetCellValue(i, 5, str(item.value))
		self.mainWindow.doorPrizesTable.SetCellValue(i, 6, item.contact)
		self.mainWindow.doorPrizesTable.SetCellValue(i, 7, item.phone)
		self.mainWindow.doorPrizesTable.SetCellValue(i, 8, item.email)
		self.mainWindow.doorPrizesTable.SetCellValue(i, 9, item.streetAddress)
		self.mainWindow.doorPrizesTable.SetCellValue(i, 10, item.city)
		self.mainWindow.doorPrizesTable.SetCellValue(i, 11, item.state)
		self.mainWindow.doorPrizesTable.SetCellValue(i, 12, item.zipcode)
		self.mainWindow.doorPrizesTable.SetCellValue(i, 13, item.mailAddress)
		self.mainWindow.doorPrizesTable.SetCellValue(i, 14, item.mailCity)
		self.mainWindow.doorPrizesTable.SetCellValue(i, 15, item.mailState)
		self.mainWindow.doorPrizesTable.SetCellValue(i, 16, item.mailZipcode)
		self.mainWindow.doorPrizesTable.SetCellValue(i, 17, item.eaplContact)
		
	def addRaffleItems(self, event): # add an item to the Raffle Items auction
		newRaffleItem = publicClass.GiveAwayItem()
		self.displayRaffleItem(newRaffleItem)
		self.raffleItems.append(newRaffleItem)
		event.Skip()

	def deleteRaffleItems(self, event): # delete an item from the Raffle Items auction
		selectedRow = self.mainWindow.raffleItemsTable.GetGridCursorRow()
		self.mainWindow.raffleItemsTable.DeleteRows(selectedRow, 1, True)
		del(self.raffleItems[selectedRow])
		event.Skip()

	def sortRaffleItems(self, event): # sort the Raffle Items auction items
		print "Event handler `sortRaffleItemss' not implemented!"
		event.Skip()

	def searchRaffleItems(self, event): # search the Raffle Items auction items
		print "Event handler `searchRaffleItems' not implemented!"
		event.Skip()

	def reportRaffleItems(self, event): # generate a report of the Raffle Items auction items
		self.reportWindow = reportGeneratorGUI.createReportGeneratorWindow(self, "Generate Raffle Items Report", ["Donor", "Contact", "Date", "Phone", "Street Address", "City", "State", "Zip", "Mailing Address", "Mailing City", "Mailing State", "Mailing Zip", "E-mail", "Value", "Item Number", "Category", "Item", "EAPL Contact"])
		event.Skip()

	def startRaffleItemsAuction(self, event): # start a RaffleItems auction
		print "Event handler `startRaffleItemsAuction' not implemented!"
		event.Skip() 
	
	def openRaffleItemsRapidEntry(self, event): # Open the rapid entry window
		self.rapidEntryWindow = rapidEntryGUI.createRapidEntryWindow(self, self.mainWindow, "Raffle Items Rapid Entry", ["Donor:", "Contact:", "Date:", "Phone:", "Street Address:", "City:", "State:", "Zip:", "Mailing Address:", "Mailing City:", "Mailing State:", "Mailing Zip:", "E-mail:", "Value:", "Item Number:", "Category:", "Item:", "EAPL Contact:"])
		self.disableRapidEntryButtons()
		self.rapidOutput = 4
		event.Skip()
	
	def changeRaffleItemsInfo(self, event): # Called when a change is made to the raffle items table
		print "changing item data"
		col = event.GetCol()
		i = event.GetRow()
		if col == 0: self.raffleItems[i].date = self.mainWindow.raffleItemsTable.GetCellValue(i, col)
		elif col == 1: self.raffleItems[i].itemNum = self.mainWindow.raffleItemsTable.GetCellValue(i, col)
		elif col == 2: self.raffleItems[i].donor = self.mainWindow.raffleItemsTable.GetCellValue(i, col)
		elif col == 3: self.raffleItems[i].category = self.mainWindow.raffleItemsTable.GetCellValue(i, col)
		elif col == 4: self.raffleItems[i].item = self.mainWindow.raffleItemsTable.GetCellValue(i, col)
		elif col == 5: self.raffleItems[i].value = float(self.mainWindow.raffleItemsTable.GetCellValue(i, col))
		elif col == 6: self.raffleItems[i].contact = self.mainWindow.raffleItemsTable.GetCellValue(i, col)
		elif col == 7: self.raffleItems[i].phone = self.mainWindow.raffleItemsTable.GetCellValue(i, col)
		elif col == 8: self.raffleItems[i].email = self.mainWindow.raffleItemsTable.GetCellValue(i, col)
		elif col == 9: self.raffleItems[i].streetAddress = self.mainWindow.raffleItemsTable.GetCellValue(i, col)
		elif col == 10: self.raffleItems[i].city = self.mainWindow.raffleItemsTable.GetCellValue(i, col)
		elif col == 11: self.raffleItems[i].state = self.mainWindow.raffleItemsTable.GetCellValue(i, col)
		elif col == 12: self.raffleItems[i].zip = self.mainWindow.raffleItemsTable.GetCellValue(i, col)
		elif col == 13: self.raffleItems[i].mailAddress = self.mainWindow.raffleItemsTable.GetCellValue(i, col)
		elif col == 14: self.raffleItems[i].mailCity = self.mainWindow.raffleItemsTable.GetCellValue(i, col)
		elif col == 15: self.raffleItems[i].mailState = self.mainWindow.raffleItemsTable.GetCellValue(i, col)
		elif col == 16: self.raffleItems[i].mailZip = self.mainWindow.raffleItemsTable.GetCellValue(i, col)
		elif col == 17: self.raffleItems[i].eaplContact = self.mainWindow.raffleItemsTable.GetCellValue(i, col)
		event.Skip()

	def startRaffleItemsAuction(self, event): # start a GiveAway auction
		print "Event handler `startRaffleItemsAuction' not implemented!"
		event.Skip()
	
	def displayRaffleItem(self, item):
		self.mainWindow.raffleItemsTable.AppendRows(1, True)
		i = self.mainWindow.raffleItemsTable.GetNumberRows()-1 # New row number
		self.mainWindow.raffleItemsTable.SetCellValue(i, 0, item.date)
		if item.itemNum == -1: self.mainWindow.raffleItemsTable.SetCellValue(i, 1, "Not Avail.")
		else: self.mainWindow.raffleItemsTable.SetCellValue(i, 1, item.itemNum)
		self.mainWindow.raffleItemsTable.SetCellValue(i, 2, item.donor)
		self.mainWindow.raffleItemsTable.SetCellValue(i, 3, item.category)
		self.mainWindow.raffleItemsTable.SetCellValue(i, 4, item.item)
		self.mainWindow.raffleItemsTable.SetCellValue(i, 5, str(item.value))
		self.mainWindow.raffleItemsTable.SetCellValue(i, 6, item.contact)
		self.mainWindow.raffleItemsTable.SetCellValue(i, 7, item.phone)
		self.mainWindow.raffleItemsTable.SetCellValue(i, 8, item.email)
		self.mainWindow.raffleItemsTable.SetCellValue(i, 9, item.streetAddress)
		self.mainWindow.raffleItemsTable.SetCellValue(i, 10, item.city)
		self.mainWindow.raffleItemsTable.SetCellValue(i, 11, item.state)
		self.mainWindow.raffleItemsTable.SetCellValue(i, 12, item.zipcode)
		self.mainWindow.raffleItemsTable.SetCellValue(i, 13, item.mailAddress)
		self.mainWindow.raffleItemsTable.SetCellValue(i, 14, item.mailCity)
		self.mainWindow.raffleItemsTable.SetCellValue(i, 15, item.mailState)
		self.mainWindow.raffleItemsTable.SetCellValue(i, 16, item.mailZipcode)
		self.mainWindow.raffleItemsTable.SetCellValue(i, 17, item.eaplContact)

	def addCashItem(self, event): # add a cash donation
		newCashItem = publicClass.CashDonation()
		self.mainWindow.cashTable.AppendRows(1, True)
		self.cashDonations.append(newCashItem)
		event.Skip()

	def deleteCashItem(self, event): # delete a cash dontaion
		selectedRow = self.mainWindow.cashTable.GetGridCursorRow()
		self.mainWindow.cashTable.DeleteRows(selectedRow, 1, True)
		del(self.cashDonations[selectedRow])
		event.Skip()

	def sortCashItems(self, event): # sort the cash donations
		print "Event handler `sortCashItems' not implemented!"
		event.Skip()

	def searchCash(self, event): # search the cash donations
		print "Event handler `searchCash' not implemented!"
		event.Skip()

	def reportCash(self, event): # report the cash donations
		self.reportWindow = reportGeneratorGUI.createReportGeneratorWindow(self, "Generate Cash Donations", ["Donor", "Contact", "Date", "Phone", "Street Address", "City", "State", "Zip", "E-mail", "Value", "Donation Level", "Cash", "Check", "Donation", "Tickets", "Shirts", "Mugs", "Sponsor"])
		event.Skip()
	
	def openCashRapidEntry(self, event): # Open the rapid entry window
		self.rapidEntryWindow = rapidEntryGUI.createRapidEntryWindow(self, self.mainWindow, "Cash Donation Rapid Entry", ["Donor:", "Contact:", "Date:", "Phone:", "Street Address:", "City:", "State:", "Zip:", "E-mail:", "Value:", "Donation Level:", "Total:"], ["Cash", "Check", "Donation", "Tickets", "Shirts", "Mugs", "Sponsor"])
		self.disableRapidEntryButtons()
		self.rapidOutput = 5
		event.Skip()
	
	def changeCashInfo(self, event): # Called when a change is made to the cash donations table
		print "changing item data"
		col = event.GetCol()
		i = event.GetRow()
		if col == 0: self.cashDonations[i].date = self.mainWindow.cashTable.GetCellValue(i, col)
		elif col == 1: self.cashDonations[i].donor = self.mainWindow.cashTable.GetCellValue(i, col)
		elif col == 2: self.cashDonations[i].contact = self.mainWindow.cashTable.GetCellValue(i, col)
		elif col == 3: self.cashDonations[i].streetAddress= self.cashDonations[i].mailAddres = self.mainWindow.cashTable.GetCellValue(i, col)
		elif col == 4: self.cashDonations[i].city = self.cashDonations[i].mailCity = self.mainWindow.cashTable.GetCellValue(i, col)
		elif col == 5: self.cashDonations[i].state = self.cashDonations[i].mailState = self.mainWindow.cashTable.GetCellValue(i, col)
		elif col == 6: self.cashDonations[i].zip = self.cashDonations[i].mailZip = self.mainWindow.cashTable.GetCellValue(i, col)
		elif col == 7: self.cashDonations[i].phone = self.mainWindow.cashTable.GetCellValue(i, col)
		elif col == 8: self.cashDonations[i].email = self.mainWindow.cashTable.GetCellValue(i, col)
		elif col == 9: self.cashDonations[i].value = float(self.mainWindow.cashTable.GetCellValue(i, col))
		elif col == 10: 
			if self.mainWindow.cashTable.GetCellValue(i, col) != "": self.cashDonations[i].cash == True
			else: self.cashDonations[i].cash == False
		elif col == 11: 
			if self.mainWindow.cashTable.GetCellValue(i, col) != "": self.cashDonations[i].check == True
			else: self.cashDonations[i].check == False
		elif col == 12: 
			if self.mainWindow.cashTable.GetCellValue(i, col) != "": self.cashDonations[i].donation == True
			else: self.cashDonations[i].donation == False
		elif col == 13: 
			if self.mainWindow.cashTable.GetCellValue(i, col) != "": self.cashDonations[i].tickets == True
			else: self.cashDonations[i].tickets == False
		elif col == 14: 
			if self.mainWindow.cashTable.GetCellValue(i, col) != "": self.cashDonations[i].shirts == True
			else: self.cashDonations[i].shirts == False
		elif col == 15: 
			if self.mainWindow.cashTable.GetCellValue(i, col) != "": self.cashDonations[i].mugs == True
			else: self.cashDonations[i].mugs == False
		elif col == 16: 
			if self.mainWindow.cashTable.GetCellValue(i, col) != "": self.cashDonations[i].sponsor == True
			else: self.cashDonations[i].sponsor == False
		elif col == 17: 
			if self.mainWindow.cashTable.GetCellValue(i, col) != "": self.cashDonations[i].other == True
			else: self.cashDonations[i].other == False
		elif col == 18: self.cashDonations[i].donorLevel = self.mainWindow.cashTable.GetCellValue(i, col)
		elif col == 19: self.cashDonations[i].total = float(self.mainWindow.cashTable.GetCellValue(i, col))
		event.Skip()
	
	def displayCashDonation(self, item):
		self.mainWindow.cashTable.AppendRows(1, True)
		i = self.mainWindow.cashTable.GetNumberRows()-1 # New row number
		
		# Put in the straight forward stuff
		self.mainWindow.cashTable.SetCellValue(i, 0, item.date)
		self.mainWindow.cashTable.SetCellValue(i, 1, item.donor)
		self.mainWindow.cashTable.SetCellValue(i, 2, item.contact)
		self.mainWindow.cashTable.SetCellValue(i, 3, item.streetAddress)
		self.mainWindow.cashTable.SetCellValue(i, 4, item.city)
		self.mainWindow.cashTable.SetCellValue(i, 5, item.state)
		self.mainWindow.cashTable.SetCellValue(i, 6, item.zipcode)
		self.mainWindow.cashTable.SetCellValue(i, 7, item.phone)
		self.mainWindow.cashTable.SetCellValue(i, 8, item.email)
		self.mainWindow.cashTable.SetCellValue(i, 9, str(item.value))
		self.mainWindow.cashTable.SetCellValue(i, 18, item.donationLevel)
		self.mainWindow.cashTable.SetCellValue(i, 19, str(item.total))
		
		# Put in the true / false stuff
		if item.cash: self.mainWindow.cashTable.SetCellValue(i, 10, "X")
		if item.check: self.mainWindow.cashTable.SetCellValue(i, 11, "X")
		if item.donation: self.mainWindow.cashTable.SetCellValue(i, 12, "X")
		if item.tickets: self.mainWindow.cashTable.SetCellValue(i, 13, "X")
		if item.shirts: self.mainWindow.cashTable.SetCellValue(i, 14, "X")
		if item.mugs: self.mainWindow.cashTable.SetCellValue(i, 15, "X")
		if item.sponsor: self.mainWindow.cashTable.SetCellValue(i, 16, "X")
		if item.other: self.mainWindow.cashTable.SetCellValue(i, 17, "X")

	def addExpenseItem(self, event): # add an expense
		newExpense = publicClass.Expense()
		self.displayExpense(newExpense)
		self.expenses.append(newExpense)
		event.Skip()

	def deleteExpenseItem(self, event): # delete an expense
		selectedRow = self.mainWindow.expenseTable.GetGridCursorRow()
		self.mainWindow.expenseTable.DeleteRows(selectedRow, 1, True)
		del(self.expenses[selectedRow])
		event.Skip()

	def sortExpenseItems(self, event): # sort the expenses
		print "Event handler `sortExpenseItems' not implemented!"
		event.Skip()

	def searchExpense(self, event): # search the expenses
		print "Event handler `searchExpense' not implemented!"
		event.Skip()

	def reportExpense(self, event): # generate a report of the expenses
		self.reportWindow = reportGeneratorGUI.createReportGeneratorWindow(self, "Generate Expense Donations", ["Date", "Payee", "Amount", "Payer", "Advertising", "Banners", "Paper Goods", "Shirts", "Mugs", "Stamps", "Other", "Total"])
		event.Skip()
	
	def openExpenseRapidEntry(self, event): # Open the rapid entry window
		self.rapidEntryWindow = rapidEntryGUI.createRapidEntryWindow(self, self.mainWindow, "Expense Rapid Entry", ["Date:", "Payee:", "Amount:", "Payer:", "Total:"], ["Advertising", "Banners", "Paper Goods", "Shirts", "Mugs", "Stamps", "Other"])
		self.disableRapidEntryButtons()
		self.rapidOutput = 6
		event.Skip()
	
	def changeExpenseInfo(self, event): # Called when a change is made to the expense table
		print "changing item data"
		col = event.GetCol()
		i = event.GetRow()
		if col == 0: self.expenses[i].date = self.mainWindow.expenseTable.GetCellValue(i, col)
		elif col == 1: self.expenses[i].payee = self.mainWindow.expenseTable.GetCellValue(i, col)
		elif col == 2: self.expenses[i].amount = float(self.mainWindow.expenseTable.GetCellValue(i, col))
		elif col == 3: self.expenses[i].payer = self.expenses[i].mailAddres = self.mainWindow.expenseTable.GetCellValue(i, col)
		elif col == 4: 
			if self.mainWindow.expenseTable.GetCellValue(i, col) != "": self.expenses[i].advertising == True
			else: self.expenses[i].advertising == False
		elif col == 5: 
			if self.mainWindow.expenseTable.GetCellValue(i, col) != "": self.expenses[i].banners == True
			else: self.expenses[i].banners == False
		elif col == 6: 
			if self.mainWindow.expenseTable.GetCellValue(i, col) != "": self.expenses[i].paperGoods == True
			else: self.expenses[i].paperGoods == False
		elif col == 7: 
			if self.mainWindow.expenseTable.GetCellValue(i, col) != "": self.expenses[i].shirts == True
			else: self.expenses[i].shirts == False
		elif col == 8: 
			if self.mainWindow.expenseTable.GetCellValue(i, col) != "": self.expenses[i].mugs == True
			else: self.expenses[i].mugs == False
		elif col == 9: 
			if self.mainWindow.expenseTable.GetCellValue(i, col) != "": self.expenses[i].stamps == True
			else: self.expenses[i].stamps == False
		elif col == 10: 
			if self.mainWindow.expenseTable.GetCellValue(i, col) != "": self.expenses[i].other == True
			else: self.expenses[i].other == False
		elif col == 11: self.expenses[i].total = float(self.mainWindow.expenseTable.GetCellValue(i, col))
		event.Skip()
	
	def displayExpense(self, item):
		self.mainWindow.expenseTable.AppendRows(1, True)
		i = self.mainWindow.expenseTable.GetNumberRows()-1 # New row number
		
		# Put in the straight forward stuff
		self.mainWindow.expenseTable.SetCellValue(i, 0, item.date)
		self.mainWindow.expenseTable.SetCellValue(i, 1, item.payee)
		self.mainWindow.expenseTable.SetCellValue(i, 2, str(item.amount))
		self.mainWindow.expenseTable.SetCellValue(i, 3, item.payer)
		if item.advertising: self.mainWindow.expenseTable.SetCellValue(i, 4, 'X')
		if item.banners: self.mainWindow.expenseTable.SetCellValue(i, 5, 'X')
		if item.paperGoods: self.mainWindow.expenseTable.SetCellValue(i, 6, 'X')
		if item.shirts: self.mainWindow.expenseTable.SetCellValue(i, 7, 'X')
		if item.mugs: self.mainWindow.expenseTable.SetCellValue(i, 8, 'X')
		if item.stamps: self.mainWindow.expenseTable.SetCellValue(i, 9, 'X')
		if item.other: self.mainWindow.expenseTable.SetCellValue(i, 10, 'X')
		self.mainWindow.expenseTable.SetCellValue(i, 11, str(item.total))
	
	def addNewRapidEntry(self, event): # Adds a new item from the rapid entry window
		if self.rapidOutput == 0: # Move around the values and put them in the table
			print "Entering silent auction item"
			newSilentItem = publicClass.SilentAuctionItem(self.rapidEntryWindow.windowFieldDic['Donor:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Contact:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Phone:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Street Address:'].GetValue(), self.rapidEntryWindow.windowFieldDic['City:'].GetValue(), self.rapidEntryWindow.windowFieldDic['State:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Zip:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Date:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Mailing Address:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Mailing City:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Mailing State:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Mailing Zip:'].GetValue(), self.rapidEntryWindow.windowFieldDic['E-mail:'].GetValue(), float(self.rapidEntryWindow.windowFieldDic['Value:'].GetValue()), self.rapidEntryWindow.windowFieldDic['Item Number:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Category:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Item:'].GetValue(), self.rapidEntryWindow.windowFieldDic['EAPL Contact:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Sold For:'].GetValue())
			if newSilentItem.soldFor == "": newSilentItem.soldFor = 0 # Make sure we get a float in the end
			else: newSilentItem.soldFor = float(newSilentItem.soldFor)
			self.displaySilentItem(newSilentItem)
			self.silentAuctionItems.append(newSilentItem)
		if self.rapidOutput == 1: # Move around the values and put them in the table
			print "Entering live auction item"
			newLiveItem = publicClass.LiveAuctionItem(self.rapidEntryWindow.windowFieldDic['Donor:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Contact:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Phone:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Street Address:'].GetValue(), self.rapidEntryWindow.windowFieldDic['City:'].GetValue(), self.rapidEntryWindow.windowFieldDic['State:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Zip:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Date:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Mailing Address:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Mailing City:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Mailing State:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Mailing Zip:'].GetValue(), self.rapidEntryWindow.windowFieldDic['E-mail:'].GetValue(), float(self.rapidEntryWindow.windowFieldDic['Value:'].GetValue()), self.rapidEntryWindow.windowFieldDic['Item Number:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Category:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Item:'].GetValue(), self.rapidEntryWindow.windowFieldDic['EAPL Contact:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Sold For:'].GetValue())
			if newLiveItem.soldFor == "": newLiveItem.soldFor = 0 # Make sure we get a float in the end
			else: newLiveItem.soldFor = float(newLiveItem.soldFor)
			self.displayLiveItem(newLiveItem)
			self.liveAuctionItems.append(newLiveItem)
		if self.rapidOutput == 2: # Move around the values and put them in the table
			print "Entering give away item"
			newGiveAway = publicClass.GiveAwayItem(self.rapidEntryWindow.windowFieldDic['Donor:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Contact:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Phone:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Street Address:'].GetValue(), self.rapidEntryWindow.windowFieldDic['City:'].GetValue(), self.rapidEntryWindow.windowFieldDic['State:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Zip:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Date:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Mailing Address:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Mailing City:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Mailing State:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Mailing Zip:'].GetValue(), self.rapidEntryWindow.windowFieldDic['E-mail:'].GetValue(), float(self.rapidEntryWindow.windowFieldDic['Value:'].GetValue()), self.rapidEntryWindow.windowFieldDic['Item Number:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Category:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Item:'].GetValue(), self.rapidEntryWindow.windowFieldDic['EAPL Contact:'].GetValue())
			self.displayGiveAway(newGiveAway)
			self.giveAwayItems.append(newGiveAway)
		if self.rapidOutput == 3: # Move around the values and put them in the table
			print "Entering door prize"
			newDoorPrize = publicClass.GiveAwayItem(self.rapidEntryWindow.windowFieldDic['Donor:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Contact:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Phone:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Street Address:'].GetValue(), self.rapidEntryWindow.windowFieldDic['City:'].GetValue(), self.rapidEntryWindow.windowFieldDic['State:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Zip:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Date:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Mailing Address:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Mailing City:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Mailing State:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Mailing Zip:'].GetValue(), self.rapidEntryWindow.windowFieldDic['E-mail:'].GetValue(), float(self.rapidEntryWindow.windowFieldDic['Value:'].GetValue()), self.rapidEntryWindow.windowFieldDic['Item Number:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Category:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Item:'].GetValue(), self.rapidEntryWindow.windowFieldDic['EAPL Contact:'].GetValue())
			self.displayDoorPrize(newDoorPrize)
			self.doorPrizes.append(newDoorPrize)
		if self.rapidOutput == 4: # Move around the values and put them in the table
			print "Entering raffle item"
			newRaffleItem = publicClass.GiveAwayItem(self.rapidEntryWindow.windowFieldDic['Donor:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Contact:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Phone:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Street Address:'].GetValue(), self.rapidEntryWindow.windowFieldDic['City:'].GetValue(), self.rapidEntryWindow.windowFieldDic['State:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Zip:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Date:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Mailing Address:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Mailing City:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Mailing State:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Mailing Zip:'].GetValue(), self.rapidEntryWindow.windowFieldDic['E-mail:'].GetValue(), float(self.rapidEntryWindow.windowFieldDic['Value:'].GetValue()), self.rapidEntryWindow.windowFieldDic['Item Number:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Category:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Item:'].GetValue(), self.rapidEntryWindow.windowFieldDic['EAPL Contact:'].GetValue())
			self.displayRaffleItem(newRaffleItem)
			self.raffleItems.append(newRaffleItem)
		if self.rapidOutput == 5: # Move around the values and put them in the table
			print "Entering cash donation"
			newCashDonation = publicClass.CashDonation(self.rapidEntryWindow.windowFieldDic['Total:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Donor:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Contact:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Phone:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Street Address:'].GetValue(), self.rapidEntryWindow.windowFieldDic['City:'].GetValue(), self.rapidEntryWindow.windowFieldDic['State:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Zip:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Date:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Street Address:'].GetValue(), self.rapidEntryWindow.windowFieldDic['City:'].GetValue(), self.rapidEntryWindow.windowFieldDic['State:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Zip:'].GetValue(), self.rapidEntryWindow.windowFieldDic['E-mail:'].GetValue(), float(self.rapidEntryWindow.windowFieldDic['Value:'].GetValue()), self.rapidEntryWindow.windowCheckDic['Cash'].GetValue(), self.rapidEntryWindow.windowCheckDic['Check'].GetValue(), self.rapidEntryWindow.windowCheckDic['Donation'].GetValue(), self.rapidEntryWindow.windowCheckDic['Tickets'].GetValue(), self.rapidEntryWindow.windowCheckDic['Shirts'].GetValue(), self.rapidEntryWindow.windowCheckDic['Mugs'].GetValue(), self.rapidEntryWindow.windowCheckDic['Sponsor'].GetValue())
			self.displayCashDonation(newCashDonation)
			self.cashDonations.append(newCashDonation)
		if self.rapidOutput == 6: # Move around the values and put them in the table
			print "Entering expense item"
			newExpense = publicClass.Expense(self.rapidEntryWindow.windowFieldDic['Date:'].GetValue(), self.rapidEntryWindow.windowFieldDic['Payee:'].GetValue(), float(self.rapidEntryWindow.windowFieldDic['Amount:'].GetValue()), self.rapidEntryWindow.windowFieldDic['Payer:'].GetValue(), self.rapidEntryWindow.windowCheckDic['Advertising'].GetValue(), self.rapidEntryWindow.windowCheckDic['Banners'].GetValue(), self.rapidEntryWindow.windowCheckDic['Paper Goods'].GetValue(), self.rapidEntryWindow.windowCheckDic['Shirts'].GetValue(), self.rapidEntryWindow.windowCheckDic['Mugs'].GetValue(), self.rapidEntryWindow.windowCheckDic['Stamps'].GetValue(), self.rapidEntryWindow.windowCheckDic['Other'].GetValue(), float(self.rapidEntryWindow.windowFieldDic['Total:'].GetValue()))
			self.displayExpense(newExpense)
			self.expenses.append(newExpense)
		event.Skip()
	
	def generateReport(self, event): # Create a report from the report generator window
		print "report generator not ready"
		event.Skip()
	
	def disableRapidEntryButtons(self): # Keeps from having more than one rapid entry window open at once (unlike enableRapidEntryButtons, it is not called with an event)
		# Diable the rapid entry buttons
		self.mainWindow.silentRapidEntryButton.Enable(False)
		self.mainWindow.liveRapidEntryButton.Enable(False)
		self.mainWindow.cashRapidEntryButton.Enable(False)
		self.mainWindow.giveAwayRapidEntryButton.Enable(False)
		self.mainWindow.silentRapidEntryButton.Enable(False)
		self.mainWindow.doorPrizesRapidEntryButton.Enable(False)
		self.mainWindow.raffleItemsRapidEntryButton.Enable(False)
		self.mainWindow.expenseRapidEntryButton.Enable(False)
	
	def enableRapidEntryButtons(self, event):
		# Re-Enable the rapid entry buttons
		self.mainWindow.silentRapidEntryButton.Enable(True)
		self.mainWindow.liveRapidEntryButton.Enable(True)
		self.mainWindow.cashRapidEntryButton.Enable(True)
		self.mainWindow.giveAwayRapidEntryButton.Enable(True)
		self.mainWindow.silentRapidEntryButton.Enable(True)
		self.mainWindow.doorPrizesRapidEntryButton.Enable(True)
		self.mainWindow.raffleItemsRapidEntryButton.Enable(True)
		self.mainWindow.expenseRapidEntryButton.Enable(True)
		
		# Close the window
		self.rapidEntryWindow.Destroy()
		
		event.Skip()
	
application = eaplOPTS()
